import sim

def launch (switch_type = sim.config.default_switch_type, host_type = sim.config.default_host_type):
  """
  Creates a topology with loops.

  It looks like:
         h2  
         |        
         B    
       / | \ 
  h1--A  |  D--h4
       \ | /
         C
         |
         h3
  """

  switch_type.create('A')
  switch_type.create('B')
  switch_type.create('C')
  switch_type.create('D')


  host_type.create('h1')
  host_type.create('h2')
  host_type.create('h3')
  host_type.create('h4')
  
  A.linkTo(h1)
  B.linkTo(h2)
  C.linkTo(h3)
  D.linkTo(h4)

  A.linkTo(B, latency=2)
  A.linkTo(C, latency=7)
  B.linkTo(D, latency=3)
  C.linkTo(D, latency=1)
  B.linkTo(C, latency=1)    
#   s1.linkTo(h1a)
#   s1.linkTo(h1b)
#   s2.linkTo(h2a)
#   s2.linkTo(h2b)

#   s1.linkTo(s3, latency=3)
#   s3.linkTo(s2, latency=2)

#   s1.linkTo(s4)
#   s4.linkTo(s5, latency=2)
#   s5.linkTo(s2)